@extends('admin::layouts.master')

@section('content')
    <div class="col-lg-12">
        <div class="card card-table">
                <div class="card-header">
                    角色管理
                </div>
                <div class="xs-mt-30 xs-mb-20 text-center">
                    <a href="" class="btn btn-space btn-success md-trigger">角色列表</a>
                    <button data-toggle="modal" data-target="#addRole" type="button" class="btn btn-space btn-primary">添加角色</button>
                </div>
                @component('components.modal',['title'=>'添加角色','url'=>'/admin/role','id'=>'addRole'])
                <div class="form-group">
                    <label><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">中文名称</font></font></label>
                    <input type="text" name="title" placeholder="请输入角色中文名称..." class="form-control">
                </div>
                <div class="form-group">
                    <label><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">英文标识</font></font></label>
                    <input type="text" name="name" placeholder="请输入角色英文标识..." class="form-control">
                </div>

                @endcomponent
                <div class="card-body">

                <table class="table">
                    <thead>
                    <tr>
                        <th>编号</th>
                        <th>中文名称</th>
                        <th>英文标识</th>
                        <th class="actions">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    @foreach($role as $v)
                        <tr>
                            <td>{{$v['id']}}</td>
                            <td>{{$v['title']}}</td>
                            <td>{{$v['name']}}</td>
                            <td class="actions">
                                <div class="btn-group btn-space">
                                    <button data-toggle="modal" data-target="#roleEdit{{$v['id']}}" type="button" class="btn btn-space btn-primary">编辑</button>

                                @component('components.modal',['title'=>'编辑角色','url'=>'/admin/role/'. $v['id'],'id'=>'roleEdit'.$v['id'],'method'=>'PUT'])
                                        <div class="form-group text-left">
                                            <label><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">中文名称</font></font></label>
                                            <input type="text" name="title" value="{{$v['title']}}" class="form-control">
                                        </div>
                                        <div class="form-group text-left">
                                            <label><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">英文标识</font></font></label>
                                            <input type="text" name="name" value="{{$v['name']}}"  class="form-control">
                                        </div>
                                    @endcomponent
                                    <form action="/admin/role/{{$v['id']}}" method="post">
                                        @csrf
                                        @method('DELETE')
                                        <button type="submit" class="btn btn-danger">删除</button>
                                    </form>
                                    <a href="{{route('showPermission',$v['id'])}}" style="height: 30px;border: 1px solid transparent;" class="btn btn-success ml-1">权限分配</a>
                                </div>
                            </td>
                        </tr>
                        @endforeach
                    </tbody>
                </table>
            </div>
        </div>
    </div>
@stop
